﻿@{
    ViewBag.Title = "加工计划";
    Layout = "~/Views/Shared/_LayoutList.cshtml";
}
@(       
 Html.nbGridFor<MaterialProcessPlanView>(s =>
 {
     s.Action("PlanList");
     s.ExtParam(new { date = DateTime.Today.AddDays(1) });
     s.Columns(c =>
     {
         c.Bind(m => m.Id).IsKey();
         c.BindDateTime(m => m.Date).Width(70).Title("订单日期").AsSearch();
         c.BindEnum(m => m.BigClass, "BigClass").Width(60).Title("品名大类");
         c.BindEnum(m => m.Category, "MaterialCategory").Width(60).Title("品名分类");
         c.Bind(m => m.Code).Width(60).AsQuery().Title("编号").AsSearch().AsQuery();
         c.Bind(m => m.Name).Width(100).AsQuery().Align(GridAlign.Left).Title("名称").AsSearch().AsQuery();
         c.Bind(m => m.ProcessWeight).Width(70).Align(GridAlign.Right).Title("加工量(斤)");
         c.Bind(m => m.ProcessRate).Width(50).Title("加工率").AsSearch().Align(GridAlign.Right).Process("FormatProcessRate");
         c.Bind(m => m.RawMaterialName).Width(100).Title("所需原材料").AsSearch().Align(GridAlign.Left);
         c.Bind(m => m.TotalWeight).Width(70).Align(GridAlign.Right).Title("订单量(斤)");
         c.Bind(m => m.ActualStorage).Width(70).Align(GridAlign.Right).Title("实际库存(斤)");
         c.Bind(m => m.SafeStorage).Width(70).Align(GridAlign.Right).Title("安全库存(斤)");
     });
     s.Buttons(b =>
     {
         b.BindAddButton("生成明天素菜加工单").Action(Url.Action("Edit", new { Date = DateTime.Today.AddDays(1).ToString("yyyy-MM-dd"), Type = "S" }));
         b.BindAddButton("生成明天荤菜加工单").Action(Url.Action("Edit", new { Date = DateTime.Today.AddDays(1).ToString("yyyy-MM-dd"), Type = "H" }));
     });
 }))
<script type="text/javascript">

    // 刷新列表Grid
    function refreshGrid() {
        // 操作成功提示
        showLoadingMsg("操作成功，请到加工单管理查看", { left: 300, top: 2 }, true, 3000);

        // 同步刷新列表
        $("table.flexigrid").flexReload();
    }

    function FormatProcessRate(value, id, row) {
        if (value != '') {
            return value * 100 + "%";
        }
        return value;
    }
</script>
